<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>固件升级列表</title>
    <meta name="ctx" th:content="${#httpServletRequest.getContextPath()}"/>
    <link rel="stylesheet" th:href="@{/css/admin/base-v2.css}">
    <link rel="stylesheet" th:href="@{/lib/font-awesome/4.7.0/css/font-awesome.min.css}">
    <link rel="stylesheet" th:href="@{/css/admin/app.css}">
</head>

<body>
<div class="app-page">

    <div class="app-page-content">

        <div class="app-card">
            <div class="app-card-body">
                <div class="app-card-body-con">

                    <div class="z-btn-group">
                        <a th:href="@{goAddFirmware}" data-title="新增" class="j-btn-control z-btn z-primary layer-open">新增</a>
                    </div>


                    <table class="z-table">
                        <thead>
	                        <th>固件名称</th>
	                        <th>更新时间</th>
	                        <th>版本名称</th>
	                        <!-- <th>版本号</th> -->
	                        <th>适用机型</th>
	                        <th>大小（单位：M）</th>
	                        <th>说明</th>
	                        <th>操作</th>
                        </thead>
                        <tbody>
	                        <tr th:each="firm: ${firmList}" th:attr="data-id=${firm.deviceUpgradeId},data-name=${firm.upgradeName},data-model=${firm.modelName},
                        data-size=${firm.size},data-description=${firm.description},data-url=${firm.url}">
	                            <td><a class="btn-detail" th:text="${firm.upgradeName}"></a></td>
	                            <td th:text="${firm.updateTimeDesc}"></td>
	                            <td th:text="${firm.versionName}"></td>
	                            <!-- <td th:text="${apk.versionCode}"></td> -->
	                            <td th:text="${firm.modelName}"></td>
	                            <td th:text="${firm.size}"></td>
	                            <td th:text="${firm.description}"></td>
	                            <td>
	                                <a class="btn-update layer-open" th:href="@{goUpgradeFirmware(deviceUpgradeId=${firm.deviceUpgradeId})}" data-title="编辑">编辑</a>
	                                <a th:href="@{firmDeviceList(deviceUpgradeId=${firm.deviceUpgradeId})}" class="btn-deposit layer-open" data-title="升级">升级</a>
	                            </td>
	                        </tr>
                        </tbody>
                    </table>

                    <!-- 分页信息 -->
	                <div class="app-card-body">
	                	<div class="table-info z-pat z-fl">
                       		总计：<p class="total" th:text="${total}"></p>
                        </div>
	                    <!-- 前端分页 -->
	                    <div class="pagination z-pat z-fr"></div>
	                </div>

                </div>
            </div>
        </div>
    </div>
</div>

<script th:src="@{/lib/jquery.min.js}"></script>
<script th:src="@{/lib/layer-v3.1.1/layer/layer.js}"></script>
<script th:src="@{/js/form.js}"></script>
<script th:src="@{/js/admin/app.js}"></script>
<script th:src="@{/js/pagination.js}"></script>
<script th:src="@{/js/popup.js}"></script>
<script>
	//获取context path
	var context = $("meta[name='ctx']").attr("content");
	//处理分页
    var pageNum = [[${pageNum}]];
    var pageSize = [[${pageSize}]];
    var total = [[${total}]];
	
    // 加载select联动内容
    $('[name="searchType"] option').each(function (index, element) {
        if ((App.query.searchType === undefined && index === 0) || App.query.searchType == $(this).val()) {
            $('.j-option-switch .content').html($(".search").children('div').eq(index).html())
        }
    })

    // 从URL加载搜索数据
    $(".filter").formLoad(App.query);

    var pagination = new Pagination(".pagination", {
        pageIndex: pageNum, // 当前页数
        pageSize: pageSize, // 每页数量
        count: total, // 总条数
        maxButtonCount: 5, // 分页按钮数量(可选)
        // 分页切换事件
        onPageChanged: function (pageIndex) {
            var url = context + "/firmware/list";
            var paramStr = createParamStr(pageIndex, pageSize);
            if(paramStr !== ""){
                paramStr = paramStr.substring(1);
                url = url + "?" + paramStr;
            }
            window.location.href = url;
        }
    });
	
    /**
     * 创建参数字符串
     * @param pageIndex 当前页
     * @param pageSize 每页条数
     * @returns {string} 参数字符串
     */
    function createParamStr(pageIndex, pageSize) {
    	var url = "";
        if(!isBlank(pageIndex)){
            url = url + "&pageNum=" + pageIndex;
        }
        if(!isBlank(pageSize)){
            url = url + "&pageSize=" + pageSize;
        }
        return url;
    }
     

   	 //检查参数
     function isBlank(param) {
         if(undefined === param){
             return true;
         }
         if(null == param){
             return true;
         }
         if("" === param){
             return true;
         }
         return false;
     }
   	 
</script>
<script>
</script>

</body>

</html>